package com.yang.controller.data;


import com.yang.dto.UserDto;
import com.yang.service.UserService;
import com.yang.utils.ThreadLocalUtil;
import com.yang.vo.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "用户模块")
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;


    @ApiOperation("获取个人中心信息")
    @GetMapping("/info")
    public ResponseResult getUserInfo(){
        log.info("获取id为{}用户信息", ThreadLocalUtil.get());
        return userService.getUserInfo();
    }

    @ApiOperation("修改用户个人信息")
    @PutMapping("/info")
    public ResponseResult updateUserInfo(@RequestBody UserDto userDto){
        log.info("id为{}的用户修改了个人信息:\n{}",ThreadLocalUtil.get(),userDto);
        return userService.updateUserInfo(userDto);
    }


}
